The Universal Serial Bus (USB) Mass Storage Class is a set of computing communication protocols defined by the USB Implementers Forum (USB-IF) that run on the USB. The USB Mass Storage Class comprises two transport protocols: (1) USB Mass Storage Class Control/Bulk/Interrupt (CBI) Transport; and (2) USB Mass Storage Class Bulk-Only Transport. The USB Mass Storage Class further comprises the following subclass specifications: (1) USB Mass Storage Class ATA Command Block; (2) USB Mass Storage Class UFI Command Specification; (3) USB Mass Storage Class RBC Command Specification; (4) USB Mass Storage Class QIC-157 Command Specification; (5) USB Mass Storage Class SFF-8070i Command Specification; and (6) SCSI transparent command set. The aforementioned transport protocols define the transport methods of data, commands, and status information on the USB: The CBI Transport specification defines how to transmit data, commands, and status information by using Control, Bulk In/Out, and Interrupt endpoints, while the Bulk-Only Transport specification defines the way that data, commands, and status information are transmitted by only using a bulk endpoint. Most USB storage devices are designed based on the Bulk-Only Transport specification and the SCSI transparent command set. Bulk-Only Transport uses bulk transport in most communications and uses control transport only when clearing a stall condition on a bulk endpoint and when transmitting a class-specific request.
Usually, a storage device (e.g., a HDD) following the Bulk-Only Transport specification to be connected to a computer is called a USB mass storage device. Typically, a storage device communicating with a computer through the USB Bulk-Only Transport protocol is called a USB bulk-only mass storage device. Such devices are widely used in personal computers and embedded systems, such as a disk (e.g., USB disk, floppy disk, CD, DVD), a multi-function media card reader, a mobile phone, a camera, and a scanner.
A USB bulk-only mass storage device supports logical units that share common device characteristics. A logical unit may be a physical storage unit or a logical address space, each identified by a logical unit number (LUN).
FIG. 1 is a schematic diagram illustrating a USB mass storage system having a plurality of logical units. As shown in FIG. 1, a mass storage device 10 is connected to a host computer 15 through a USB bulk-only interface 11. The mass storage device 10 comprises local logical units 12 and remote logical units 13, which can be either physical devices, logical address spaces connected to the mass storage device through a network, other interfaces, or various virtualization techniques. In some applications, it may be necessary to dynamically add a new logical unit to the mass storage device or to dynamically remove an existing logical unit from it when the device is being used.
FIG. 2 is a structural block diagram illustrating a USB mass storage system. As shown in FIG. 2, the system comprises a USB mass storage driver stack 20 and a USB host controller 21 on a host computer (i.e., host) as well as a USB mass storage device 22. The mass storage driver stack 20 is of a multilayer structure. The lower layers of the USB mass storage driver stack 20 may include a USB controller driver 201 and a USB core driver 202, which are responsible for the transmission of the data on the USB bus. The USB core driver 202 provides a group of common interfaces for USB drivers to access and control the USB hardware (i.e., a host controller and a mass storage device) without having to worry about the type of USB host controller 21 used in the system. The middle layer of the USB mass storage driver stack 20 is a USB mass storage driver 203, which is responsible for implementing various subclass specifications and transport protocols, such as the typical SCSI transparent subclass specification and the Bulk-Only Transport protocol. The upper layer of the USB mass storage driver stack 20 is a storage medium access driver. For most USB bulk-only mass storage devices, specific storage medium access operations are generally implemented through SCSI commands; accordingly, the uppermost layer of the USB mass storage driver stack 20 is generally a SCSI driver 204. However, one skilled in the art can understand that, for different subclass specifications, the upper layers of a USB mass storage driver stack may have different drivers. The USB mass storage driver 203 contains device-specific configuration information and provides proper interfaces to an upper layer storage medium access driver (SCSI driver 204) to allow it to communicate with the USB mass storage device 22 via different subclass specifications and transport protocols. The USB mass storage driver 203 also needs to deliver the device information to an upper layer driver, which is a SCSI driver for most bulk-only devices. The SCSI driver 204 considers each valid logical unit as an independent storage resource. The SCSI driver 204 will create an internal SCSI device object for each logical unit and register for each device object an individual access point in a file system (e.g., /dev/scd* or /dev/sd* in a Linux system). Through such access points, user-mode applications can send operating requests to the SCSI driver 204, which in turn translates the operating requests into specific SCSI commands and transmits them to the USB mass storage driver 203 through internal SCSI device objects for ultimate arrival at the USB mass storage device 22.
In general, a normal boot process of a USB bulk-only mass storage device includes three levels of initializations:
1. Level 1—USB Core Driver Initialization
When a USB mass storage device is attached, the host USB core driver is responsible for assigning a unique address to device. The host also requests configuration information from the device to determine its capabilities and characteristics. The device may have one or more kinds of configurations. Within each configuration, the device may support a plurality of interfaces. An interface is a related set of endpoints that present a single feature or function to the host. A typical USB bulk-only mass storage device comprises a Default Control Pipe (endpoint 0) and a bulk-only interface.
2. Level 2—USB Mass Storage Device Class Initialization
The USB mass storage driver issues a class-specific request—“Get max LUN”—to the Default Control Pipe and determines the number of logical units supported by the device according to the returned result. The logical units of the mass storage device shall be numbered contiguously starting from LUN 0 to a maximum LUN of 15 (0x0F in hexadecimal). Furthermore, the USB mass storage driver shall allocate required resources, record corresponding information, and report the storage device to SCSI drivers.
3. Level 3—SCSI Layer Initialization
The SCSI drivers shall issue an inquiry command to each logical unit numbered from 0 to maximum LUN to complete the initialization procedure. Each logical unit is considered as an individual storage device, and the response to the inquiry command indicates the characteristics of these individual storage devices. Finally, the SCSI drivers will present all of the storage devices to the operating system.
In such manner, a USB bulk-only mass storage device accomplishes its boot process. Consequently, the logical units are rendered operational.
Although current USB technology allows USB device hot plug and play, the USB mass storage device according to the prior art does not support hot plug and play of its logical units. Generally, “hot plug and play” may refer to the ability to dynamically modify, remove, and/or add a component (e.g., a USB device or the logical units thereof) connected to a machine (e.g., a computing device) without substantially interfering with the interaction between the component and the machine.
FIGS. 3 and 4 are sequence charts illustrating the process of adding and removing the logical units of the mass storage device according to the prior art, respectively. As shown in FIGS. 3 and 4, when inserting logical units into the mass storage device or removing logical units from the mass storage device, the mass storage device must be disconnected from the USB bus. Once the host is notified that the mass storage device has been removed, the USB mass storage driver will inform the SCSI driver to remove all of the logical units. Then, the mass storage device reconfigures its own logical units and reconnects to the USB bus. The host reinitializes the device; the USB mass storage driver obtains the maximum number of logical units supported by the mass storage device through the “Get max LUN” request and reports it to the SCSI driver, which will transmit an inquiry command to each logical unit currently connected with the mass storage device in order to complete the initialization process. Such series of operations causes the host USB core driver to start a new boot process and to reinitialize all of the logical units after the addition or removal of logical units. Thus, currently running applications using these logical units are disrupted, although such applications may only communicate with the unchanged logical units and thus should not be interrupted in theory.
Since addition and removal of logical units in accordance with the prior art causes interruption of running applications, the performance, availability, and reliability of running applications may be seriously impacted. Thus, a more intelligent USB mass storage device is needed that can support the hot plug and play of its logical units.